<template>
	<u-popup mode='right' :show="show" :round="10"  @close="close">
	
		<u-navbar title="动态审核" border @leftClick="close" placeholder>
		</u-navbar>
		<view style="padding: 0 40rpx;width:100vw;
    box-sizing: border-box;">
			<u-form labelPosition="left" :model="form" ref="uForm">
				<u-form-item labelPosition='top' label="描述:" prop="remark" borderBottom>
					<view class="mt20">
						<u--textarea v-model="form.remark" placeholder="请输入描述"></u--textarea>
					</view>
				</u-form-item>
				<u-form-item labelPosition='top' label="状态:" prop="status" borderBottom>
					<view class="mt20 flex">
						<text :class="{active:item.id==form.status}" class="statusItem" v-for="item in statusList"
							:key="item.id" @click="form.status=item.id">{{item.name}}</text>
					</view>
				</u-form-item>
			</u-form>
			<view class="mt20">
				<u-button text="确认" :disabled="disabled" @click='submit'></u-button>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: ['show'],
		data() {
			return {
				statusList: [{
						id: '2',
						name: '通过'
					},
					{
						id: '1',
						name: '驳回'
					}
				],
				disabled: false,
				form: {
					remark: '',
					status: null
				},
				rules: {
					'remark': {
						type: 'string',
						required: true,
						message: '请填写描述',
						trigger: ['blur', 'change']
					},
					'status': {
						type: 'string',
						required: true,
						message: '请选择状态',
						trigger: ['blur', 'change']
					},
				},
			}
		},
		mounted() {
			this.$refs.uForm.setRules(this.rules)
		},
		methods: {
			close() {
				if (this.disabled) return
				this.$emit('close')
			},
			submit() {
				this.disabled = true
				this.$refs.uForm.validate().then(res => {
					this.$api_company.Active.Verify(this.show, this.form).then(res => {
						this.disabled = false
						this.close()
						this.$emit('reload')
						this.form = {
							remark: '',
							status: null
						}
					})
				}).catch(errors => {
					this.disabled = false
					uni.$u.toast('请输入完整信息')
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mt20 {
		margin-top: 20rpx;
	}

	.flex {
		display: flex;

	}

	.statusItem {
		border-radius: 8rpx;
		margin-right: 10rpx;
		border: 1rpx solid #f1f1f1;
		font-size: 24rpx;
		padding: 5rpx 20rpx;
	}

	.active {
		background-color: #3975c6;
		color: #fff;
		border: none;
	}
</style>